﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListPC.aspx.cs" Inherits="ZX.WebApp.Crm.Customer.ListPC" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/menu/assets/skins/sam/menu.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/fonts/fonts-min.css" />
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <script language="javascript" type="text/javascript">        
    //function document.oncontextmenu() { event.returnValue = false; } //屏蔽鼠标右键
        //新增客户信息
        function fnAddNew1() {
            parent.parent.addTabs('新增客户信息', '../Crm/Customer/AddCustomer.aspx?entity=CrmCustomer&flag=1');
            parent.parent.NeedRefreshPage = this;
        }
        //新增客户信息
        function addCustomerTemp(id) {
            if (id != undefined) {
                window.parent.parent.$("#tabs").tabs('close', '修改客户信息');
                parent.parent.addTabs('修改客户信息', '../Crm/Customer/AddCustomer.aspx?entity=CrmCustomer&flag=2&id=' + id);
            }
            else {
                parent.parent.addTabs('新增客户信息', '../Crm/Customer/AddCustomer.aspx?entity=CrmCustomer&flag=1');
            }
            parent.parent.NeedRefreshPage = this;
        }
        //修改客户信息
        function fnEdit1() {
            var o = $("input[type=checkbox]");
            var spanArr = [];
            var LastSelected = "";
            var tempNum = 0;
            var index = -1
            spanArr = $("span[type=checkbox]");
            o.each(function () {
                index = index + 1;
                if (this.checked) {
                    tempNum = tempNum + 1;
                    LastSelected = ((spanArr[index]).className);
                }
            }
            );

            if (tempNum == 1) {
                addCustomerTemp(LastSelected);
                // __doPostBack("btnModifyTrans", "");
            } else {
                alert("请选择一条记录");
                return;
            }
        }
        //双击选择
        function tbDbClick(obj) {
            var ingc;
            for (ingc = 0; ingc < obj.all.length; ingc++) {
                if (obj.all(ingc).type == 'checkbox') {
                    var idss = obj.all(ingc).id.length;
                    if (idss > 0) {
                        document.getElementById(obj.all(ingc).id).checked = !document.getElementById(obj.all(ingc).id).checked;
                    }
                }
            }
        }
        //刷新
        function fnReload() {
            __doPostBack("btnTree", "");

        }
        //新增客户信息
        function addLinkManTemp(id) {
            if (id != undefined) {
                parent.parent.addTabs('新增联系人信息', '../Crm/Customer/EditCrmLinkMan.aspx?entity=CrmLinkMan&cid=' + id);
            }
            else {
                parent.parent.addTabs('新增联系人信息', '../Crm/Customer/EditCrmLinkMan.aspx?entity=CrmLinkMan');
            }
            parent.parent.NeedRefreshPage = this;
        }
        //联系人信息
        function fnAddNew2() {
            var o = $("input[type=checkbox]");
            var spanArr = [];
            var LastSelected = "";
            var tempNum = 0;
            var index = -1
            spanArr = $("span[type=checkbox]");
            o.each(function () {
                index = index + 1;
                if (this.checked) {
                    tempNum = tempNum + 1;
                    LastSelected = ((spanArr[index]).className);
                }
            }
            );

            if (tempNum == 1) {
                addLinkManTemp(LastSelected);
                // __doPostBack("btnModifyTrans", "");
            } else {
                alert("请选择一条记录");
                return;
            }
        }
        //私海转公海
        function fnSetRole1() {
            var o = $("input[type=checkbox]");
            var arr = [];
            var tempNum = 0;
            o.each(function () {  
                arr.push(this.checked);
                if (this.checked) {
                    tempNum = tempNum + 1;
                }
            }
            );
            $("#TextBox1").val(arr.join(","));
            if (tempNum == 0) {
                alert("请选择一条记录");
                return;
            }
            if (confirm("您确定要把私海转为公海吗?")) {
                __doPostBack("btnTrans", "");
            }
        }
        //新增约场
        function fnCheck() {
            var o = $("input[type=checkbox]");
            var spanArr = [];
            var LastSelected = "";
            var tempNum = 0;
            var index = -1
            spanArr = $("span[type=checkbox]");
            o.each(function () {
                index = index + 1;
                if (this.checked) {
                    tempNum = tempNum + 1;
                    LastSelected = ((spanArr[index]).className);
                }
            }
            );

            if (tempNum == 1) {
                manageActivityTemp(LastSelected);
                // __doPostBack("btnModifyTrans", "");
            } else {
                alert("请选择一条记录");
                return;
            }
        }
        //新增约场
        function manageActivityTemp(id) {
            if (id != undefined) {
                parent.parent.addTabs('新增工作记录', '../Crm/Customer/EditCrmActivity.aspx?entity=CrmActivity&cid=' + id);

            } else {
                parent.parent.addTabs('新增工作记录', '../Crm/Customer/EditCrmActivity.aspx?entity=CrmActivity');
            } parent.parent.NeedRefreshPage = this;
        }
        //转约场订单
        var Url = "../../Extend/AjaxData/CustomOperating.aspx";
        var fnOrderFieldTemp = function (vid) {
            var SaveUrl = Url + "?r=" + Math.random() + "&action=check&entity=CheckCustomerOrder&json=" + vid;
            YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
                success: function (res) {
                    try {
                        var str = res.responseText;
                        if (str == "1") {
                            window.parent.parent.$("#tabs").tabs('close', '新增约场订单');
                            var pagetitle = "新增约场订单";
                            parent.parent.addTabs(pagetitle, '../Crm/Sale/AddOrderField.aspx?r=' + Math.random() + '&flag=0&cid=' + vid + '&entity=CrmCustomerOrder&title=' + encodeURI(pagetitle));
                            parent.parent.NeedRefreshPage = this;
                        } else if (str == "2") {
                            alert("该客户已添加约场订单!");
                        }
                        else {
                            alert("数据异常,操作失败!");
                        }
                    }
                    catch (e) {
                    }
                    finally {
                    }
                },
                failure: function (error) {
                    alert("数据错误：" + error.statusText);
                }
            }, null);
        }
        //转订单
        var fnOrderField = function () {
            var o = $("input[type=checkbox]");
            var spanArr = [];
            var LastSelected = "";
            var tempNum = 0;
            var index = -1;
            spanArr = $("span[type=checkbox]");
            o.each(function () {
                index = index + 1;
                if (this.checked) {
                    tempNum = tempNum + 1;
                    LastSelected = ((spanArr[index]).className);
                }
            }
            );

            if (tempNum == 1) {         
                fnOrderFieldTemp(LastSelected);
            } else {
                alert("请选择一条记录");
                return;
            }
        }
        //共享
        function fnResult1() {
            var o = $("input[type=checkbox]");
            var spanArr = [];
            var LastSelected = "";
            var tempNum = 0;
            var index = -1
            spanArr = $("span[type=checkbox]");
            o.each(function () {
                index = index + 1;
                if (this.checked) {
                    tempNum = tempNum + 1;
                    LastSelected = ((spanArr[index]).className);
                }
            }
            );

            if (tempNum == 1) {
                manageShareTemp(LastSelected);
                // __doPostBack("btnModifyTrans", "");
            } else {
                alert("请选择一条记录");
                return;
            }
        }
        //共享
        function manageShareTemp(id) {
            if (id != undefined) {
                document.getElementById("EditUIWindow").src = "ShareCustomer.aspx?r=" + Math.random() + "&type=1&entity=CrmCustomerShare&id=" + id;
                YAHOO.example.container.dialog1.show();
                document.getElementById("yui-gen17-button").style.display = "block";
            } else {
                alert("共享失败");
            }
        }
        //链接跳到修改客户信息
        function hrefModify(id) {
            window.parent.parent.$("#tabs").tabs('close', '查看客户信息');
            parent.parent.addTabs('查看客户信息', '../Crm/Customer/AddCustomer.aspx?entity=CrmCustomer&title='+encodeURI("查看客户信息")+'&id=' + id);
            parent.parent.NeedRefreshPage = this;
        }
        function closeWin() {
            YAHOO.example.container.dialog1.hide();
        }

        function GoSelect() {
            return true;
        }
        function GoSelect1(obj) {

            alert(obj);

        }
    </script>
    <style type="text/css"> 
        body
        {
            font:13px/1.231 arial,helvetica,clean,sans-serif;
            *font-size:small;
            *font:x-small; background: #eeeeee;
            text-align:center; 
        }
        a{text-decoration:none;}
        a:link,a:visited{
            color:#1f376d;
        }
        a:hover{   color:#ff0000;
            text-decoration:underline;
        }

       </style>
</head>
<body class="yui-skin-sam">
    <form id="form1" runat="server">
    <div id="toolbar" style="margin: 2px;">
        <% =BtnItems %>
        <button type="button" id="btnReload" name="btnReload">
            刷新</button>
    </div>
    <div class="fieldForm" id="fieldForm" style="overflow:auto;width:100%;height:100%">
        <asp:DataList ID="dltList" runat="server" RepeatColumns="4" DataKeyField="ID" OnItemCommand="dltList_ItemCommand"
            RepeatDirection="Horizontal">
            <ItemTemplate>
                <table style="background-image: url(../../Images/crm/bg.png); width: 200px; height: 170px;"
                    ondblclick="tbDbClick(this)">
                    <tr>
                        <td style="padding-left: 12px; padding-top: 5px;" colspan="2">
                            <table>
                                <tr>
                                    <td style="width: 151px;" align="left">
                                        <asp:CheckBox ID="chkSel" runat="server" type="checkbox" CssClass='<%#Eval("CustomId") %>'
                                            Checked="false" /><%#Eval("CustomerName") %>
                                    </td>
                                    <td>
                                        <asp:LinkButton CommandName="del" ToolTip="转为公海" OnClientClick="return confirm('您确定要把私海转为公海吗？') "
                                            CssClass="uline" ID="lbtnDel" runat="server">&nbsp;&nbsp;
                                        </asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left: 12px; text-align: right; width: 65px;">
                            客户编码：
                        </td>
                        <td>
                            <a href="javascript:void(0)" onclick="hrefModify('<%#Eval("CustomId") %>')">
                                <%#Eval("Code")%>
                            </a>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left: 12px; text-align: right;">
                            决策人：
                        </td>
                        <td>
                            <%#Eval("Decisionmaker")%>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left: 12px; text-align: right;">
                            职位：
                        </td>
                        <td>
                            <%#Eval("DecisionPosition")%>
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-left: 12px; text-align: right;">
                            手机号码：
                        </td>
                        <td>
                            <%#Eval("DecisionTel")%>
                            <asp:Label ID="hdnCid" runat="server" Text='<%#Eval("CustomId") %>' Visible="false" />
                            <asp:Label ID="hdnExplain" runat="server" Text='<%#Eval("Explain") %>' Visible="false" />
                            <asp:Label ID="hdnCuser" runat="server" Text='<%#Eval("CustomUser") %>' Visible="false" />
                        </td>
                    </tr>
                    <tr style="color:Red">
                        <td style="padding-left: 12px; padding-bottom: 5px; text-align: right;">
                            转入时间：
                        </td>
                        <td style="padding-bottom: 5px;">
                           <b> <%# GetStringFormat(Eval("AddTime"))%>
</b>                        </td>
                    </tr>
                </table>
            </ItemTemplate>
            <FooterTemplate>
            </FooterTemplate>
        </asp:DataList>
        <%if (dltList == null || dltList.Items.Count == 0)
          { %>
        <font style="color: Red;">
            <br />
            该用户还没有添加私海客户.</font>
        <%} %>
        <asp:LinkButton ID="lkPre" OnCommand="IndexChanging" CommandArgument="pre" runat="server">上一页></asp:LinkButton>
        <asp:LinkButton ID="lkNext" OnCommand="IndexChanging" CommandArgument="next" runat="server">下一页</asp:LinkButton>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            信息共享</div>
        <div class="bd">
            <iframe id="EditUIWindow" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <span style="display: none;">
        <asp:Button ID="btnTrans" runat="server" Text="Button" OnClick="btnTrans_Click" />
        <asp:Button ID="btnTree" runat="server" Text="Button" OnClick="btnTree_Click" CausesValidation="False" />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></span>
    </form>
</body>
<script language="javascript" type="text/javascript">
  
    (function () {
        var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;
        Event.onDOMReady(function () {
            var layout = new YAHOO.widget.Layout({
                units: [
                { position: 'top', height: 35, body: 'toolbar', gutter: '1 1 1 1', scroll: null, zIndex: 2 },
                { position: 'center', body: 'fieldForm', gutter: '0 1 1 1' }]
            });
            layout.render();
        });
    })();
    YAHOO.example.init = function () {
     function onButtonClick(p_oEvent) {
                 YAHOO.log("You clicked button: " + this.get("id"), "info", "example1");
                 switch(this.get("id"))
                 { 
                     <% =InitBtnEvents %>
                     case "btnReload":
                         fnReload();
                         break;
                    default:
                         break;
                 }                        
        }
    YAHOO.util.Event.onContentReady("toolbar", function () {
    parent.parent.unContextMenu(document);
     <% =BtnEvents  %>
      var btnReload = new YAHOO.widget.Button("btnReload");
        btnReload.on("click", onButtonClick);
    });     }();
    YAHOO.namespace("example.container");
    YAHOO.util.Event.onDOMReady(function () {
        var handleSubmit = function () {
            var editwindow = document.getElementById("EditUIWindow");
            if (editwindow) {
                editwindow.contentWindow.Save();
            }
        };
        var handleCancel = function () {
            this.cancel();
        };
        var handleSuccess = function (o) {
            var response = o.responseText;
            response = response.split("<!")[0];
            document.getElementById("resp").innerHTML = response;
        };
        var handleFailure = function (o) {
            alert("Submission failed: " + o.status);
        };
        var const_EditWindowWidth = "<% =650 %>px",
		const_EditWindowHeight = "<% =450 %>px";
        YAHOO.util.Dom.removeClass("dialog1", "yui-pe-content");
        YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
							    { width: const_EditWindowWidth,
							        height: const_EditWindowHeight,
							        fixedcenter: true,
							        visible: false,
							        draggable: true,
							        close: true,
							        autofillheight: "body",
							        constraintoviewport: true,
							        buttons: [{ text: "保存", handler: handleSubmit, isDefault: true },
								          { text: "取消", handler: handleCancel}]
							    });
        YAHOO.example.container.dialog1.validate = function () {
            var data = this.getData();
            if (data.firstname == "" || data.lastname == "") {
                alert("Please enter your first and last names.");
                return false;
            } else {
                return true;
            }
        };
        YAHOO.example.container.dialog1.callback = { success: handleSuccess,
            failure: handleFailure
        };
        YAHOO.example.container.dialog1.render();

        //拖动大小
        var resize = new YAHOO.util.Resize("dialog1", {
            handles: ["br"],
            autoRatio: false,
            minWidth: 650,
            minHeight: 450,
            status: false
        });
        resize.on("startResize", function (args) {
            if (this.cfg.getProperty("constraintoviewport")) {
                var D = YAHOO.util.Dom;

                var clientRegion = D.getClientRegion();
                var elRegion = D.getRegion(this.element);

                resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
                resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
            } else {
                resize.set("maxWidth", null);
                resize.set("maxHeight", null);
            }

        }, YAHOO.example.container.dialog1, true);
        resize.on("resize", function (args) {
            var panelHeight = args.height;
            this.cfg.setProperty("height", panelHeight + "px");
        }, YAHOO.example.container.dialog1, true);
    });
   
</script>
</html>
